package com.yupi.example.consumer;

import org.yaml.snakeyaml.Yaml;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Map;

public class ReadConfigFile {

    public static void main(String[] args) {
        Yaml yaml = new Yaml();
        
        try {
            FileInputStream input = new FileInputStream("E:\\yu-rpc\\example-consumer\\src\\main\\resources\\example.yaml");
            Map<String, Object> yamlData = yaml.load(input);
            
            Map<String, Object> databaseConfig = (Map<String, Object>) yamlData.get("database");
            String host = (String) databaseConfig.get("host");
            int port = (int) databaseConfig.get("port");
            String username = (String) databaseConfig.get("username");
            String password = (String) databaseConfig.get("password");
            
            System.out.println("Database Port: " + port);
            System.out.println("Database Username: " + username);
            System.out.println("Database Password: " + password);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}